<?php

use think\facade\Route;

$miss = function () {
    $arr = [
        'code' => -1,
        'msg' => '请输入正确的路由地址',
        'data' => []
    ];
    return json($arr);
};
// 主页路由
Route::miss($miss);
// 只需要验证token的放在一起
$func = function () {
    Route::group('user', function () {
        Route::get('detail', 'app\\admin\\controller\\AdminUser@detail');
    });
    //任务
    Route::group('task', function () {
        Route::get('', 'app\\admin\\controller\\Task@query');
        Route::get('/:id', 'app\\admin\\controller\\Task@read');
        Route::post('', 'app\\admin\\controller\\Task@add');
        Route::put('/:id', 'app\\admin\\controller\\Task@edit');
        Route::delete('/:id', 'app\\admin\\controller\\Task@delete');
    });
    //商品
    Route::group('good', function () {
        Route::get('', 'app\\admin\\controller\\Good@query');
        Route::get('/:id', 'app\\admin\\controller\\Good@read');
        Route::get('exchange/list', 'app\\admin\\controller\\VerifyGoods@query');
        Route::post('', 'app\\admin\\controller\\Good@add');
        Route::put('/:id', 'app\\admin\\controller\\Good@edit');
        Route::delete('/:id', 'app\\admin\\controller\\Good@delete');
    });
    //任务订单
    Route::group('taskRecord', function () {
        Route::get('', 'app\\admin\\controller\\TaskRecord@query');
        Route::get(':id', 'app\\admin\\controller\\TaskRecord@read');
        Route::put(':id/enable', 'app\\admin\\controller\\TaskRecord@enable');
        Route::put(':id/disable', 'app\\admin\\controller\\TaskRecord@disable');
    });
    //用户
    Route::group('member', function () {
        Route::get('', 'app\\admin\\controller\\Member@query');
    });
    //轮播图
    Route::group('banner', function () {
        Route::get('', 'app\\admin\\controller\\Banner@query');
        Route::get('/:id', 'app\\admin\\controller\\Banner@read');
        Route::post('', 'app\\admin\\controller\\Banner@add');
        Route::put('/:id', 'app\\admin\\controller\\Banner@edit');
        Route::delete('/:id', 'app\\admin\\controller\\Banner@delete');
    });
    //消息
    Route::group('notification', function () {
        Route::get('', 'app\\admin\\controller\\Notification@query');
        Route::get('/:id', 'app\\admin\\controller\\Notification@read');
        Route::post('', 'app\\admin\\controller\\Notification@add');
        Route::put('/:id', 'app\\admin\\controller\\Notification@edit');
        Route::delete('/:id', 'app\\admin\\controller\\Notification@delete');
    });
};
Route::post('user/login', 'app\\admin\\controller\\AdminUser@login');
Route::post('upload', 'app\\admin\\controller\\Upload@index');
Route::group('wx', function () {

});
Route::group('', $func)->middleware(app\common\middleware\TokenCheck::class)->allowCrossDomain()->completeMatch(true);